# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
#import webrepl
#webrepl.start()
import time
from WIFI import WiFi
from Light import Lighter
from DateTime import DateTime

if __name__ == '__main__':
    wifi_ssid = ""
    wifi_pwd = ""

    wifi = WiFi()
    lighter = Lighter()

    count = 0
    lighter.blink(0.3)
    print("searching...")
    while not wifi.exist(wifi_ssid):
        time.sleep(1)
        count += 1
        print(f"WIFI:[{wifi_ssid}]not found,{count}")
        print([str(ssid[0] ) for ssid in wifi.wifi_list])

    print("connecting...")
    lighter.blink(1)
    wifi.connect(wifi_ssid, wifi_pwd)

    print("connected")
    lighter.on()

    date_time = DateTime()
    date_time.sync_time()
    print(date_time.get_formatted_time())


